
<template>
    <div class="model-form">
        <el-page-header @back="goBack" content="更新优惠券">
        </el-page-header>
        <div class="model-content">
            <el-form ref="ruleForm" :rules="rules" :model="form" label-width="160px">
                <el-row :gutter="10">
    <el-col :span="20">
            <el-form-item label="名称"  prop="name">
        <el-input v-model="form.name" name="name">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="封面"  prop="logo">
        <avatar v-model="form.logo"></avatar>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="面额"  prop="money">
        <el-input v-model="form.money" name="money">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="使用门槛"  prop="minPrice">
        <el-input-number v-model="form.minPrice" name="minPrice" type="textarea" :min="0" :max="99999999.99"  style="width: 100%;" ></el-input-number>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="每人限领"  prop="limitNum">
        <el-input-number v-model="form.limitNum" name="limitNum" :min="0" :max="9999999" style="width: 100%;"></el-input-number>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="发放开始时间"  prop="sendBeginTime">
        <el-date-picker v-model="form.sendBeginTime" type="datetime" value-format="YYYY-MM-DD  HH:mm:ss"
                        placeholder="选择日期">
        </el-date-picker>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="发放截止时间"  prop="sendEndTime">
        <el-date-picker v-model="form.sendEndTime" type="datetime" value-format="YYYY-MM-DD  HH:mm:ss"
                        placeholder="选择日期">
        </el-date-picker>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="有效期类型"  prop="expireType">
        <nb-select catalog="expireType" v-model="form.expireType"></nb-select>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="优惠券开始时间"  prop="useBeginTime">
        <el-date-picker v-model="form.useBeginTime" type="datetime" value-format="YYYY-MM-DD  HH:mm:ss"
                        placeholder="选择日期">
        </el-date-picker>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="优惠券截止时间"  prop="useEndTime">
        <el-date-picker v-model="form.useEndTime" type="datetime" value-format="YYYY-MM-DD  HH:mm:ss"
                        placeholder="选择日期">
        </el-date-picker>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="固定天数"  prop="useDay">
        <el-input-number v-model="form.useDay" name="useDay" :min="0" :max="9999999" style="width: 100%;"></el-input-number>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="活动范围"  prop="couponScope">
        <el-input v-model="form.couponScope" name="couponScope">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="卡券库存"  prop="stock">
        <el-input-number v-model="form.stock" name="stock" :min="0" :max="9999999" style="width: 100%;"></el-input-number>
            </el-form-item>

    </el-col>
    <el-col :span="20">
            <el-form-item label="使用说明"  prop="note">
        <el-input v-model="form.note" name="note" type="textarea"></el-input>
            </el-form-item>

    </el-col>

                    <el-col :span="22">
                        <el-form-item>
                            <el-button @click="goBack">取消</el-button>
                            <el-button type="primary" @click="updateData">确定</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
    </div>
</template>

<script setup>
    import nbSelect from "@/components/nbSelect.vue";
    import avatar from "@/components/avatar.vue";
import {ref} from "vue";
import {useData} from "@/utils/useData";
import {useUpdate} from "@/uses/useUpdate";

const form = ref({
     name: '',
     logo: '',
     money: '',
     minPrice: '',
     limitNum: '',
     sendBeginTime: '',
     sendEndTime: '',
     expireType: '',
     useBeginTime: '',
     useEndTime: '',
     useDay: '',
     couponScope: '',
     stock: '',
     note: ''})

const rules = ref({
   name: [
       {required: true, message: '请输入名称', trigger: 'blur'}
   ],
})

const ruleForm = ref(null);

const {updateData,goBack}=useUpdate("couponRule",form,ruleForm)

</script>

<style scoped>

</style>